package morning.cat;

import com.alibaba.dubbo.common.logger.Logger;
import com.alibaba.dubbo.common.logger.LoggerFactory;
import org.springframework.context.support.AbstractXmlApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * Service Bootstrap
 */
public class SpringProviderBootstrap {

    private static Logger logger = LoggerFactory.getLogger(SpringProviderBootstrap.class);
    public static AbstractXmlApplicationContext context = null;

    /**
     * 启动入口
     */
    public static void main(String[] args) {

        try {
            logger.warn("starting...");
            context = new ClassPathXmlApplicationContext(
                    "classpath:config/applicationContext*.xml");
            if (context != null) {
                context.start();
                logger.warn("service started successfully.");
                System.in.read(); // press any key to exit
            }
        } catch (Exception e) {
            logger.error("init error", e);
            if (context != null) {
                logger.info("context close.");
                context.close();
                context = null;
            }
        }
    }

}
